<?php
/**
 * 消息推送模型
 * 
 * @author  Lee<a605333742@gmail.com>
 * @time    2016-08-14
 */
namespace Model;
use Think\Model;

class MessageModel extends Model{
    /*
     * 新增推送信息
     * 
     * @return #
     */
    public function edit($where){
        if($this->add($where)){
            $data=array(
                'user_id'   =>session("authId"),
                'content'   =>'新增了名为 '.$where['name'].' 的推送信息',
                'add_time'  =>time()
            );
            if(M("Log")->add($data)){
                return TRUE;
            }else{
                return FALSE;
            }
        }else{
            return FALSE;
        }
    }
    
    /*
     * 删除推送记录
     * 
     * @return #
     */
    public function del($where){
        $g  =$where['id'];
        if(is_array($where['id'])){
            $g  =implode(',',$where['id']);
            $where['id']=array("in",implode(',',$where['id']));            
        }
        if($this->save($where)){
            $data=array(
                "user_id"   =>session("authId"),
                'content'   =>"删除了id为 ".$g." 的推送信息",
                "add_time"  =>time()
            );
            if(M("Log")->add($data)){
                return TRUE;
            }else{
                return FALSE;
            }
        }
    }
}